package com.senjoeson.baselib_ui.adapter

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter

/**
 * @author sunqiao
 * @date 2018/5/28 15:09
 * @function  主要用于vp的adapter
 */

class MyPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {

    private var tilte: Array<String>? = null
    private var mFragments: List<Fragment>? = null


    fun setTilte(tilte: Array<String>) {
        this.tilte = tilte
    }

    fun setFragments(fragments: List<Fragment>) {
        mFragments = fragments
    }

    override fun getItem(position: Int): Fragment {
        return mFragments!![position]
    }

    override fun getCount(): Int {
        return tilte!!.size
    }

    override fun getPageTitle(position: Int): CharSequence {
        return tilte!![position]
    }
}
